#!/usr/bin/env python
#coding=utf-8
#refer to:http://wiki.wxpython.org/Widget%20Inspection%20Tool

import sys
import wx
import wx.lib.mixins.inspection

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title)

        st1=wx.StaticText(self, -1, 'please press ctrl+alt+i')        
        button1=wx.Button(self, -1, u'按钮1')
        button2=wx.Button(self, -1, u'按钮2')

        hbox=wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(st1,proportion=0, flag=wx.ALL, border=5)
        hbox.Add(button1,proportion=0, flag=wx.ALL, border=5)
        hbox.Add(button2,proportion=0, flag=wx.ALL, border=5)        
        self.SetSizer(hbox)
        #self.Fit()
        
        self.Bind(wx.EVT_BUTTON, self.showipt, button1)
        
    def showipt(self, evt):
        import wx.lib.inspection
        wx.lib.inspection.InspectionTool().Show()

class MyApp(wx.App, wx.lib.mixins.inspection.InspectionMixin):
    def OnInit(self):
        self.Init()  # initialize the inspection tool
        frame = MyFrame(None, -1, title="This is a test")
        frame.Show()
        self.SetTopWindow(frame)
        return True

def test1():
    app = MyApp()
    app.MainLoop()
    
def test2():
    app = wx.App()
    frame=MyFrame(None, -1, 'inspection test')
    frame.Show()
    app.MainLoop()
    
myarg=1
if __name__ == '__main__':
    if len(sys.argv)>1:
        myarg=sys.argv[1]
    print myarg
    if myarg==1:
        test1()
    else:
        test2()
